# added by yinchao, Sat June 22 14:31	2024

# Dictionary as a set of counters

# in operator, hash_table algorithm...

fhand = open('words.txt', 'r')

words_count = {}
for line in fhand:
    words = line.split()
    for word in words:
        words_count[word] = 1 if word not in words_count else words_count[word] + 1

# print(words_count)

print('It\'s the yin word in the words_count ?', 'yin' in words_count)

# key
for key in words_count:
    print(key)

# value
for value in list(words_count.values()):
    print(value)

# value without convert to list type.
for value in words_count.values():
    print(value)

# item
for key, value in words_count.items():
    print(key, value)
